defmodule ProgContest.Fixtures.DockerImage do
  defmacro __using__(_) do
    quote location: :keep do
      alias ProgContest.DockerImages

      @valid_docker_image_attrs %{language: "Erlang", image_id: "xxxxxxxxx", code_mounting_point: "/foo"}
      @update_docker_image_attrs %{language: "Elixir", image_id: "yyyyyyyy", code_mounting_point: "/bar"}
      @invalid_docker_image_attrs %{language: nil, image_id: nil, code_mounting_point: nil}

      def docker_image_fixture(quiz, attrs \\ %{}) do
        {:ok, docker_image} =
          attrs
          |> Map.put(:quiz_id, quiz.id)
          |> Enum.into(@valid_docker_image_attrs)
          |> DockerImages.create_docker_image()

        docker_image
      end
    end
  end
end
